import request from '../utils/request'
import {isEmpty} from '@/utils/helpers'
import {ApiOption} from '@/interface/ApiInterface'


export const Http = function (api: ApiOption, params = {}) {
    if (!api || isEmpty(api.path)) {
        throw new Error('请求信息错误!!!')
    }
    const method = api.method || 'get'
    const isGet = method === 'get'
    return request(api.path, {
        method,
        data: isGet ? {} : params,
        params: isGet ? params : {}
    })
}


